package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout.LayoutParams;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.store.awk.bean.HorizonalHomeCardItemBean;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.cgz;
import o.chc;
import o.chy;
import o.dof;
import o.eiw;
import o.epv;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class HorizontalListRecommendItemCard extends HorizontalApplistItemCard {
    private int ʻॱ;
    private HorizontalApplistSingleItemCard ʽ;
    private int ˊॱ;
    private HorizontalApplistSingleItemCard ˋॱ;
    private HorizontalApplistSingleItemCard ˏॱ;
    private View ͺ;
    private View ॱˊ;
    private int ॱˎ;
    ArrayList<HorizontalApplistSingleItemCard> ᐝ = new ArrayList();
    private boolean ᐝॱ = false;

    public HorizontalListRecommendItemCard(Context context) {
        super(context);
    }

    public int ॱॱ() {
        return chc.ॱˎ();
    }

    public cgz ˏ(View view) {
        View findViewById = view.findViewById(j.ʽˋ);
        this.ʽ = new HorizontalApplistSingleItemCard(this.ʼॱ);
        findViewById.setVisibility(4);
        this.ʽ.ˏ(findViewById);
        this.ॱˊ = view.findViewById(j.ʽᐝ);
        findViewById = view.findViewById(j.ʽˊ);
        this.ˋॱ = new HorizontalApplistSingleItemCard(this.ʼॱ);
        findViewById.setVisibility(4);
        this.ˋॱ.ˏ(findViewById);
        this.ͺ = view.findViewById(j.ˊʼ);
        findViewById = view.findViewById(j.ʿॱ);
        this.ˏॱ = new HorizontalApplistSingleItemCard(this.ʼॱ);
        findViewById.setVisibility(4);
        this.ˏॱ.ˏ(findViewById);
        ʽ(view);
        if (this.ʼॱ instanceof eiw) {
            this.ᐝॱ = true;
            this.ʻॱ = this.ʼॱ.getResources().getConfiguration().orientation;
        }
        ʻ();
        return this;
    }

    public void ˋ(List<CardBean> list) {
        int i;
        if (this.ᐝॱ) {
            i = this.ʼॱ.getResources().getConfiguration().orientation;
            if (i != this.ʻॱ) {
                this.ʻॱ = i;
                ʻ();
            }
        }
        int size = list.size();
        for (int i2 = 0; i2 < size; i2++) {
            ˏ(i2, (CardBean) list.get(i2));
        }
        if (size < 3) {
            for (i = size; i < 3; i++) {
                switch (i) {
                    case 1:
                        this.ˋॱ.ॱ(4);
                        this.ॱˊ.setVisibility(4);
                        this.ͺ.setVisibility(4);
                        break;
                    case 2:
                        this.ˏॱ.ॱ(4);
                        this.ͺ.setVisibility(4);
                        break;
                    default:
                        break;
                }
            }
        }
    }

    protected void ʻ() {
        this.ˊॱ = this.ʼॱ.getResources().getDimensionPixelSize(d.י) + this.ʼॱ.getResources().getDimensionPixelSize(d.ॱˊ);
        this.ॱˎ = (this.ʼॱ.getResources().getDimensionPixelSize(d.י) + this.ʼॱ.getResources().getDimensionPixelSize(d.ˏॱ)) + epv.ˋ(this.ʼॱ, 31);
        ˉ().setLayoutParams(new LayoutParams(ˎ(this.ʼॱ, ॱॱ(), chc.ˋ()), -2));
    }

    private int ˎ(@NonNull Context context, int i, int i2) {
        return (((azb.ॱ(context) - this.ʼॱ.getResources().getDimensionPixelSize(d.ٴ)) - chc.ॱ()) - ((i - 1) * i2)) / i;
    }

    private void ˏ(int i, CardBean cardBean) {
        if (i == 0) {
            ˋ(cardBean);
        } else if (1 == i) {
            ˎ(cardBean);
        } else if (2 == i) {
            ॱ(cardBean);
        }
    }

    private void ˋ(CardBean cardBean) {
        this.ʽ.ˏ(cardBean);
        this.ʽ.ॱ(0);
        ॱ(cardBean, this.ॱˊ);
    }

    private void ˎ(CardBean cardBean) {
        this.ˋॱ.ˏ(cardBean);
        this.ˋॱ.ॱ(0);
        ॱ(cardBean, this.ͺ);
    }

    private void ॱ(CardBean cardBean, View view) {
        if (cardBean instanceof HorizonalHomeCardItemBean) {
            int i;
            LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
            if (dof.ʽ(((HorizonalHomeCardItemBean) cardBean).ʽॱ())) {
                i = this.ˊॱ;
            } else {
                i = this.ॱˎ;
            }
            layoutParams.setMarginStart(i);
            view.setLayoutParams(layoutParams);
            view.setVisibility(0);
        }
    }

    private void ॱ(CardBean cardBean) {
        this.ˏॱ.ˏ(cardBean);
        this.ˏॱ.ॱ(0);
    }

    public int ˊ() {
        return h.ॱʹ;
    }

    public int ˎ() {
        return h.ॱʹ;
    }

    public void ॱ(chy o_chy) {
        this.ʽ.ॱ(o_chy);
        this.ˋॱ.ॱ(o_chy);
        this.ˏॱ.ॱ(o_chy);
    }
}
